<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="jQuery.min.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        a {
            display: inline-block;
            width: 20px;
            height: 20px;
            border: 1px solid #ccc;
            text-align: center;
            line-height: 20px;
            text-decoration: none;
            vertical-align: bottom;

        }

        .gtext {
            height: 20px;
            width: 80px;
            border: 1px solid #ccc;
            outline: none;
            text-align: center;
        }
    </style>
</head>

<body>
    <div class="allGoods">
        <div class="goods">
            <a href="javascript:;" class="decrease">-</a>
            <input type="text" value="1" class="gtext">
            <a href="javascript:;" class="increase">+</a>
        </div>
        <div class="goods">
            <a href="javascript:;" class="decrease">-</a>
            <input type="text" value="1" class="gtext">
            <a href="javascript:;" class="increase">+</a>
        </div>
        <div class="goods">
            <a href="javascript:;" class="decrease">-</a>
            <input type="text" value="1" class="gtext">
            <a href="javascript:;" class="increase">+</a>
        </div>
    </div>
    <script>
        $(function () {
            $(".increase").click(function () {
                var n = $(this).siblings(".gtext").val();
                // console.log(n);
                n++;
                $(this).siblings(".gtext").val(n);
            });
            $(".decrease").click(function () {
                var n = $(this).siblings(".gtext").val();
                // console.log(n);
                if (n == 1) {
                    return false;
                }
                n--;
                // if (n !== 0) {
                //     $(this).siblings(".gtext").val(n);
                // }
                $(this).siblings(".gtext").val(n);
            })
        })
    </script>
</body>

</html>